#pragma once
#include<iostream>

template<class T>
class vector
{
public:
    typedef T* iterator;//这里的迭代器就是一个原生指针
    typedef const T* const_iterator;//这里的迭代器就是一个原生指针

    iterator begin()
    {
        return _start;
    }
    iterator end()
    {
        return _finish;
    }
    const_iterator begin()const
    {
        return _start;
    }
    const_iterator end()const
    {
        return _finish;
    }

    vector();
    vector(const vector& v);
    template<class InputIterator>
    vector(InputIterator first,InputIterator last);//左闭右开

    size_t size()const;
    size_t capacity()const;
    void reserve(size_t n);
    void resize(size_t n,const T val=T());

    void push_back(const T& val);
    T* insert(iterator pos,const T& val);
    T* erase(iterator pos);
    T* erase(iterator first,iterator last);
    void pop_back(){erase(end()-1);}

    T& operator[](size_t pos);
    const T& operator[](size_t pos)const;
    void swap(vector& v);
    vector& operator=(vector v){swap(v);return *this;}


    ~vector();
private:
    iterator _start=nullptr;//首地址
    iterator _finish=nullptr;//尾地址
    iterator _end_of_storage=nullptr;//容器尾巴
};